package com.andova.glcamera.device

import android.graphics.SurfaceTexture
import androidx.annotation.IntDef
import com.andova.egl.OnTextureBridger
import java.io.File

const val CAMERA_ID_0 = 0
const val CAMERA_ID_1 = 1

val ASPECT_RATIO_4_3: AspectRatio = AspectRatio.of(4, 3)
val ASPECT_RATIO_16_9: AspectRatio = AspectRatio.of(16, 9)

/**
 * Max preview width that is guaranteed by Camera2 API
 */
const val MAX_PREVIEW_WIDTH = 1920

/**
 * Max preview height that is guaranteed by Camera2 API
 */
const val MAX_PREVIEW_HEIGHT = 1080

@IntDef(CAMERA_ID_0, CAMERA_ID_1)
@Retention(AnnotationRetention.SOURCE)
annotation class CameraId

const val ANGLE_0 = 0
const val ANGLE_90 = 90
const val ANGLE_180 = 180
const val ANGLE_270 = 270

@IntDef(ANGLE_0, ANGLE_90, ANGLE_180, ANGLE_270)
@Retention(AnnotationRetention.SOURCE)
annotation class Angle

interface CameraCallback {
    fun openCamera(surfaceTexture: SurfaceTexture?, builder: CameraBuilder?)
    fun stopPreview()
    fun release()
    fun isFrameBufferUpdated(): Boolean
    fun setFrameBufferUpdated(value: Boolean)
    fun getPreviewSize(): Size
    fun getPictureSize(): Size
    fun setBuilder(builder: CameraBuilder?)
    fun getBuilder(): CameraBuilder?
    fun takePicture(out: File?, callback: (dst: File?) -> Unit)
    fun startRecord(builder: RecorderBuilder)
    fun stopRecord()
    fun resetCaptureSession()

    @CameraId
    fun getCameraId(): Int
    fun getAspectRatio(): AspectRatio
    fun isCameraOpened(): Boolean
    fun setBridger(bridger: OnTextureBridger?)
    fun getSurfaceTexture(): SurfaceTexture?
}